﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminMaster.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">

    $('.btn').live('click', function () {
        var btn = $(this).attr('id');
        switch (btn) {
            case "btnTen":
                onSuggestion(btn);
                break;
            case "btnTinhTrang":
                onSuggestion(btn);
                break;
            case "btnLoaiLopHoc":
                onSuggestion(btn);
                break;
            default:

        }
    });

    function onSuggestion(btn) {
        var search = "";

        switch (btn) {
            case "btnTen":
                {
                    search = $('#ten').val();
                    $.get('<%= ResolveUrl("~/")%>Admin/LopHoc/SearchResult', { s: search, type: "ten" },
                    function (data) {
                        $('#result').html(data);
                    });
                }
                break;
            case "btnTinhTrang":
                {
                    search = $('#tinhtrang').val();
                    $.get('<%= ResolveUrl("~/")%>Admin/LopHoc/SearchResult', { s: search, type: "tinhtrang" },
                    function (data) {
                        $('#result').html(data);
                    });
                }
                break;
            case "btnLoaiLopHoc":
                {
                    search = $('#loailophoc').val();
                    $.get('<%= ResolveUrl("~/")%>Admin/LopHoc/SearchResult', { s: search, type: "loailophoc" },
                    function (data) {
                        $('#result').html(data);
                    });
                }
                break;
            default:
                break;
        }

    }

//    $(document).bind('keydown', 'return', function (evt) {
//        alert(ev.keyCode);
//    });

//    $('#keyword').keypress(function(e){
//        alert(e.which);
//        if (e.which === 13) {
//            $('#btnSearch').click();
//        }
//    });

</script>

    <legend>
        Tìm Kiếm Lớp Học
    </legend>
    <div>
        <% using (Ajax.BeginForm("Search", "LopHoc", new AjaxOptions
           {
               InsertionMode = InsertionMode.Replace,
               HttpMethod = "GET",
               UpdateTargetId = "result"
           }))
           //Tên Đăng Nhập, Họ Tên, Email...
           { %>

               <div>
                    <label>Tên Lớp Học     :</label>
                    <input type="text" name="ten" id="ten" /> 
               </div>

                <div class="control-group">
                    <div class="controls">
                        <button id="btnTen" name="Search" type="button" class="btn btn-primary"><i class="icon-search"></i>Tìm Kiếm</button>
                    </div>
                </div>

                <div>
                    <label>Tình Trạng      :</label>
                    <%--<input type="text" name="tinhtrang" id="tinhtrang" />--%>
                    <%= Html.DropDownList("tinhtrang")%> 
                </div>

                <div class="control-group">
                    <div class="controls">
                        <button id="btnTinhTrang" name="Search" type="button" class="btn btn-primary"><i class="icon-search"></i>Tìm Kiếm</button>
                    </div>
                </div>

               <div>
                    <label>Loại Lớp Học    :</label>
                    <%--<input type="text" name="loailophoc" id="loailophoc" />--%>
                    <%= Html.DropDownList("loailophoc", "Tất Cả")%> 
               </div>

                <div class="control-group">
                    <div class="controls">
                        <button id="btnLoaiLopHoc" name="Search" type="button" class="btn btn-primary"><i class="icon-search"></i>Tìm Kiếm</button>
                    </div>
                </div>

        <% } %>
    <div id="result"></div>
    <div>
        <a href="<%=ResolveUrl("~/Admin/LopHoc/Index") %>">
        <button class="btn btn-primary">
        <i class="icon-reply"></i>
            Quay lại danh sách
        </button></a>
    </div>

    </div>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
